<template>
	<div class="mine">
		<div class="box">
			<div class="hearderBox">
				<div class="hearderBoxIcon" @click="goBack">
					<img src="../../assets/images/fanhuijiantou.png" alt="">
				</div>
				{{$t('indexTitle.title56')}}
			</div>
			<div class="proList">
				<div class="">
					<div class="magBox" :class="{focusBox:isShowOne,error:isShowOness,errorww:isShowThreessTow}">
						<div class="input-block" @click="getMsg('0')"><label for="password"
								:class="{inputblocklabel:isShowOne}">{{$t('indexTitle.title225')}}</label>
							<input :type="onetype" :class="{inputblockinput:isShowOne}" v-model="passwordOne"
								:show-password="false" @blur="blurinput('0')" @input='inputjianting(0)'>
						</div>
						<div class="action-block">
							<img src="../../assets/images/yanjingkai.png" alt="" @click="shoeEye('0')"
								v-if="isShowOneeye">
							<img src="../../assets/images/jianjingguan.png" alt="" @click="shoeEye('0')"
								v-if="!isShowOneeye">
						</div>
					</div>
					<div class="zhuyiBoxTow" v-if="isShowOness&&!isShowThreessTow">
						<img src="../../assets/images/zhuyitow.png" alt="">
						{{messageTextOne}}
					</div>
					<div class="zhuyiBoxTow" v-if="isShowThreessTow">
						<img src="../../assets/images/zhuyitow.png" alt="">
						{{messageText}}
					</div>
				</div>
				<div class="">

					<div class="magBox " :class="{focusBox:isShowTow,error:isShowTowss,errorww:isShowThreessTow}">
						<div class="input-block" @click="getMsg('1')"><label for="password"
								:class="{inputblocklabel:isShowTow}">{{$t('indexTitle.title68')}}</label>
							<input :type="twotype" :class="{inputblockinput:isShowTow}" v-model="passwordTow"
								:show-password="false" @blur="blurinput('1')" @input='inputjianting(1)'>
						</div>
						<div class="action-block">
							<img src="../../assets/images/yanjingkai.png" alt="" @click="shoeEye('1')"
								v-if="isShowToweye">
							<img src="../../assets/images/jianjingguan.png" alt="" @click="shoeEye('1')"
								v-if="!isShowToweye">
						</div>
					</div>
					<div class="zhuyiBoxTow" v-if="isShowTowss&&!isShowThreessTow">
						<img src="../../assets/images/zhuyitow.png" alt="">
						{{messageTextTow}}
					</div>
					<div class="zhuyiBox" v-if="!isShowTowss&&!isShowThreessTow">
						<img src="../../assets/images/zhuyi.png" alt="">
						{{$t('indexTitle.title69')}}
					</div>
					<div class="zhuyiBoxTow" v-if="isShowThreessTow">
						<img src="../../assets/images/zhuyitow.png" alt="">
						{{messageText}}
					</div>
				</div>
				<div class="">
					<div class="magBox" :class="{focusBox:isShowThree,error:isShowThreess,errorww:isShowThreessTow}">
						<div class="input-block" @click="getMsg('2')"><label for="password"
								:class="{inputblocklabel:isShowThree}">{{$t('indexTitle.title70')}}</label>
							<input :type="threetype" :class="{inputblockinput:isShowThree}" v-model="passwordThree"
								:show-password="false" @blur="blurinput('2')" @input='inputjianting(2)'>
						</div>
						<div class="action-block">
							<img src="../../assets/images/yanjingkai.png" alt="" @click="shoeEye('2')"
								v-if="isShowThreeeye">
							<img src="../../assets/images/jianjingguan.png" alt="" @click="shoeEye('2')"
								v-if="!isShowThreeeye">
						</div>
					</div>
					<div class="zhuyiBoxTow" v-if="isShowThreess&&!isShowThreessTow">
						<img src="../../assets/images/zhuyitow.png" alt="">
						{{messageTextThree}}
					</div>
					<div class="zhuyiBoxTow" v-if="isShowThreessTow">
						<img src="../../assets/images/zhuyitow.png" alt="">
						{{messageText}}
					</div>
				</div>
				<div class="btnssss" @click="submit()">{{$t('indexTitle.title62')}}</div>
			</div>
		<loadingFour :msgText="msgTextTow" :isShowCloseBot="isShowCloseBot"  v-if="isShowLoadingTeow" @closeGuanbiTow="closeGuanbi"></loadingFour>
		</div>
		<!-- <div class="buttons">
			<img src="../../assets/images/xiaoxi.png" alt="" />
		</div> -->
	</div>
</template>

<script>
	import {
		resetqkpassword
	} from "../../utils/api.js"
	import loadingFour from '../../components/loadingFour.vue';
	export default {
		components: {
			loadingFour
		},
		data() {
			return {
				close: true,
				isShowOne: false,
				isShowTow: false,
				isShowThree: false,
				isShowOness: false,
				isShowTowss: false,
				isShowThreess: false,
				isShowOneeye: false,
				isShowToweye: false,
				isShowThreeeye: false,
				threetype: 'password',
				twotype: 'password',
				onetype: 'password',
				passwordOne: "",
				passwordTow: "",
				passwordThree: "",

				isShowThreessTow: false,
				messageText: "",
				messageTextOne: this.$t('indexTitle.title58'),
				messageTextTow: this.$t('indexTitle.title58'),
				messageTextThree: this.$t('indexTitle.title58'),
				msgTextTow: "",
				isShowLoadingTeow: false,
				isShowCloseBot:false,
			}
		},
		created() {},
		mounted() {

		},
		methods: {
			closeGuanbi(e) {
				this.isShowLoadingTeow = false;
			},
			getMsg(num) {
				if (num == 0) {
					this.isShowOne = !this.isShowOne;
				}
				if (num == 1) {
					this.isShowTow = !this.isShowTow;
				}
				if (num == 2) {
					this.isShowThree = !this.isShowThree;
				}
			},
			inputjianting(num) {
				if (num == 0) {
					if (!this.passwordOne) {
						this.isShowOness = true;
						this.messageTextOne = this.$t('indexTitle.title58');
						this.isShowOne = !this.isShowOne;
					} else {
						this.isShowOness = false;
						this.isShowThreessTow = false;
						this.messageText = '';
					}
				}
				if (num == 1) {
					if (!this.passwordTow) {
						this.isShowTowss = true;
						this.messageTextTow = this.$t('indexTitle.title58');
						this.isShowTow = !this.isShowTow;
					} else {
						this.isShowTowss = false;
						this.isShowThreessTow = false;
						this.messageText = '';
					}
				}
				if (num == 2) {
					if (!this.passwordThree) {
						this.isShowThreess = true;
						this.messageTextThree = this.$t('indexTitle.title58');
						this.isShowThree = !this.isShowThree;
					} else {
						this.isShowThreess = false;
						this.isShowThreessTow = false;
						this.messageText = '';
					}
				}
			},
			blurinput(num) {
				if (num == 0) {
					if (!this.passwordOne) {
						this.isShowOness = true;
						this.messageTextOne = this.$t('indexTitle.title58');
						this.isShowOne = !this.isShowOne;
					} else {
						this.isShowOness = false;
					}
				}
				if (num == 1) {
					if (!this.passwordTow) {
						this.isShowTowss = true;
						this.messageTextTow = this.$t('indexTitle.title58');
						this.isShowTow = !this.isShowTow;
					} else {
						this.isShowTowss = false;
					}
				}
				if (num == 2) {
					if (!this.passwordThree) {
						this.isShowThreess = true;
						this.messageTextThree = this.$t('indexTitle.title58');
						this.isShowThree = !this.isShowThree;
					} else {
						this.isShowThreess = false;
					}
				}
			},
			shoeEye(num) {
				if (num == 0) {
					this.isShowOneeye = !this.isShowOneeye;
					if (this.onetype == 'text') {
						this.onetype = 'password'
					} else {
						this.onetype = 'text'
					}
				}
				if (num == 1) {
					this.isShowToweye = !this.isShowToweye;
					if (this.twotype == 'text') {
						this.twotype = 'password'
					} else {
						this.twotype = 'text'
					}
				}
				if (num == 2) {
					this.isShowThreeeye = !this.isShowThreeeye;
					if (this.threetype == 'text') {
						this.threetype = 'password'
					} else {
						this.threetype = 'text'
					}
				}
			},
			goBack() {
				this.$router.go(-1)
			},
			submit() {
				let that = this;
				this.isShowOness = false;
				this.isShowTowss = false;
				this.isShowThreess = false;
				this.isShowThreessTow = false;
				if (this.passwordOne == '') {
					this.isShowOness = true;
					this.messageTextOne = this.$t('indexTitle.title71');
					// this.$message.error('请输入旧密码');
					return false
				}
				if (this.passwordTow == '') {
					this.isShowTowss = true;
					this.messageTextTow = this.$t('indexTitle.title72');
					// this.$message.error('请输入新密码');
					return false
				}
				if (this.passwordThree != this.passwordTow) {
					this.isShowThreess = true;
					this.messageTextThree = this.$t('indexTitle.title65');
					// this.$message.error('两次密码不同');
					return false
				}
				let data = {
					old_password: this.passwordOne,
					password: this.passwordTow,
					password_confirmation: this.passwordThree
				}
				resetqkpassword(data).then((res) => {
					if (res.status.errorCode == 0) {
						// this.$message.success(res.status.msg);
						this.msgTextTow = res.status.msg;
						this.isShowLoadingTeow = true;
						this.isShowCloseBot = true;
							setTimeout(()=>{
								this.isShowLoadingTeow = false;
							},2000)
						// this.$message({
						// 	showClose: true,
						// 	message: res.status.msg,
						// 	type: 'success'
						// });
						setTimeout(function() {
							that.$router.go(-1)
						}, 1000)
					} else {
						this.isShowThreessTow = true;
						this.messageText = res.status.msg || this.$t('indexTitle.title66');
						// this.$message.error(res.status.msg || '更新失败');
					}
				}).catch((err) => {
					console.log(err, 'err')
				});
			}
		}
	}
</script>

<style scoped>
	* {
		box-sizing: border-box;
	}

	.mine {
		height: 90vh;
		overflow-y: auto;
		overflow-x: hidden;
		padding-top: calc(constant(safe-area-inset-top) + 0px);
		padding-top: calc(env(safe-area-inset-top) + 0px);
		padding-bottom: calc(constant(safe-area-inset-bottom) + 85px);
		padding-bottom: calc(env(safe-area-inset-bottom) + 85px);
		box-sizing: border-box;
		position: fixed;
		z-index: 1;
		-webkit-overflow-scrolling: touch;
		width: 100%;
	}

	.box {
		background-color: #ffffff;
		display: flex;
		flex-direction: column;
		/* min-height: 100vh; */
	}

	.buttons {
		position: fixed;
		bottom: 10%;
		right: 10px;
		background-color: #99D2E3;
		width: 60px;
		height: 60px;
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.buttons img {
		width: 32px;
		height: 32px;
	}


	.hearderBox {
		width: 100%;
		height: 45px;
		background-color: #fff;
		position: fixed;
		top: 0;
		font-weight: 300;
		line-height: 45px;
		text-align: center;
		font-size: 20px;
		color: #545658;
		box-shadow: inset 0 -1px 0 #ececec;
		left: 0;
		overflow: hidden;
		z-index: 99;
	}

	.hearderBoxIcon {
		width: 50px;
		position: fixed;
		top: 3px;
		left: 0px;
	}

	.hearderBoxIcon img {
		width: 20px;
		height: 20px;
	}

	.proList {
		width: 100%;
		padding: 60px 20px 0;
		box-sizing: border-box;
	}

	.magBox {
		border-radius: 5px;
		box-sizing: border-box;
		display: flex;
		height: 54px;
		justify-content: space-around;
		padding: 0 15px;
		background-color: #fbfbfb;
		border: 1px solid #e9e9e9;
		color: #777;
		margin-top: 10px;
		font-weight: 300;
	}

	.input-block {
		box-sizing: border-box;
		position: relative;
		width: 100%;
	}

	.input-block label {
		color: #a0a3a5;
		font-size: 14px;
		line-height: 1.29;
		pointer-events: none;
		position: absolute;
		top: 18px;
		transition: .2s;
		font-weight: 300;
		padding-left: 12px;
	}

	.input-block label:before {
		bottom: 0;
		color: #e94951;
		content: "*";
		font-size: 10px;
		left: 0;
		margin: auto;
		position: absolute;
		top: 4px;
	}

	.inputblocklabel {
		font-size: 10px !important;
		top: 8px !important;
	}

	.input-block input {
		background-color: transparent;
		color: #545658;
		border: none !important;
		box-sizing: border-box;
		height: 100%;
		position: absolute;
		top: 0;
		transition: .2s;
		width: 100%;
		outline: medium;
		padding: 0;
		font-family: sans-serif;
		font-size: 100%;
		line-height: 1.15;
		margin: 0;
	}

	.input-block input:focus {
		height: 28px;
		box-shadow: none;
		top: 24px;
	}

	.inputblockinput {
		height: 28px !important;
		box-shadow: none !important;
		top: 24px !important;
	}

	.focusBox {
		border: 1px solid #5235ff;
		background-color: #fff;
		border-color: rgba(114, 64, 255, .5);
		box-shadow: 0 0 0 2px rgba(114, 64, 255, .1);
	}

	.action-block {
		display: flex;
		justify-content: flex-end;
		width: 15%;
		align-items: center;
	}

	.action-block img {
		width: 20px;
		height: 20px;
	}

	.zhuyiBox img {
		width: 15px;
		height: 15px;
		margin-right: 5px;
	}

	.zhuyiBox {
		display: flex;
		font-size: 12px;
		margin: 5px 0 10px;
		color: #86898c;
		font-weight: 300;
	}

	.zhuyiBoxTow {}

	.zhuyiBoxTow img {
		width: 15px;
		height: 15px;
		margin-right: 5px;
	}

	.zhuyiBoxTow {
		display: flex;
		font-size: 12px;
		margin: 5px 0 10px;
		color: #e94951;
		font-weight: 300;
	}

	.btnssss {
		margin-top: 20px;
		background-color: #7240ff;
		border: none;
		border-radius: 3px;
		color: #fff;
		cursor: pointer;
		font-size: 16px;
		font-stretch: normal;
		font-style: normal;
		font-weight: 300;
		height: 44px;
		width: 100%;
		text-align: center;
		line-height: 44px;
	}

	.error {
		border: 1px solid #e94951;
		color: #e94951;
	}

	.errorww {
		border: 1px solid #e94951;
	}
</style>